package m.framework.test.web;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;

import m.framework.exception.SystemException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * HttpServletResponse的mock
 * 
 * @author ming
 * @date 2014年2月20日上午10:37:33
 */
public class ResponseMock implements HttpServletResponse {
	private static Logger log = LoggerFactory.getLogger(ResponseMock.class);
	//跳转页面
	private String redirect;
	private Map<String,Cookie> cookies=new HashMap();
	
	

	public String getRedirect() {
		return redirect;
	}

	public String getCharacterEncoding() {
		throw new SystemException("未实现");
	}

	public String getContentType() {
		throw new SystemException("未实现");
	}

	public ServletOutputStream getOutputStream() throws IOException {
		throw new SystemException("未实现");
	}

	public PrintWriter getWriter() throws IOException {
		throw new SystemException("未实现");
	}

	public void setCharacterEncoding(String charset) {
		throw new SystemException("未实现");
	}

	public void setContentLength(int len) {
		throw new SystemException("未实现");
	}

	public void setContentType(String type) {
		throw new SystemException("未实现");
	}

	public void setBufferSize(int size) {
		throw new SystemException("未实现");
	}

	public int getBufferSize() {
		throw new SystemException("未实现");
	}

	public void flushBuffer() throws IOException {
		throw new SystemException("未实现");
	}

	public void resetBuffer() {
		throw new SystemException("未实现");
	}

	public boolean isCommitted() {
		throw new SystemException("未实现");
	}

	public void reset() {
		throw new SystemException("未实现");
	}

	public void setLocale(Locale loc) {
		throw new SystemException("未实现");
	}

	public Locale getLocale() {
		throw new SystemException("未实现");
	}

	public void addCookie(Cookie cookie) {
		cookies.put(cookie.getName(), cookie);
	}

	public boolean containsHeader(String name) {
		throw new SystemException("未实现");
	}

	public String encodeURL(String url) {
		throw new SystemException("未实现");
	}

	public String encodeRedirectURL(String url) {
		throw new SystemException("未实现");
	}

	public String encodeUrl(String url) {
		throw new SystemException("未实现");
	}

	public String encodeRedirectUrl(String url) {
		throw new SystemException("未实现");
	}

	public void sendError(int sc, String msg) throws IOException {
		throw new SystemException("未实现");
	}

	public void sendError(int sc) throws IOException {
		throw new SystemException("未实现");
	}

	public void sendRedirect(String location) throws IOException {
		this.redirect=location;
	}

	public void setDateHeader(String name, long date) {
		throw new SystemException("未实现");
	}

	public void addDateHeader(String name, long date) {
		throw new SystemException("未实现");
	}

	public void setHeader(String name, String value) {
		throw new SystemException("未实现");
	}

	public void addHeader(String name, String value) {
		throw new SystemException("未实现");
	}

	public void setIntHeader(String name, int value) {
		throw new SystemException("未实现");
	}

	public void addIntHeader(String name, int value) {
		throw new SystemException("未实现");
	}

	public void setStatus(int sc) {
		throw new SystemException("未实现");
	}

	public void setStatus(int sc, String sm) {
		throw new SystemException("未实现");
	}
	
	public Cookie getCookie(String key) {
		return cookies.get(key);
	}

	public String getCookieContent(String key) {
		Cookie ck=cookies.get(key);
		if(ck!=null){
			return ck.getValue();
		}
		return null;
	}
}
